#include "FpHFMainWidget.h"

FP_UIBASE_BEGIN


FpHFMainWidget::FpHFMainWidget(QWidget *parent)
	: QWidget(parent)
	, ui(new Ui::FpHFMainWidgetClass())
{
	ui->setupUi(this);
	Init();
}

FpHFMainWidget::~FpHFMainWidget()
{
	delete ui;
}

void FpHFMainWidget::ShowSubWidget(QString typeName, int index)
{
	QString className = "class " + typeName;
	if (!_subMap.contains(className))
	{

	}
	if (_subWidget)
	{
		_subWidget->setParent(nullptr);
		_subWidget->setLayout(nullptr);
	}
	_subWidget = _subMap[className][index];
	if (_subWidget)
	{
		_subWidget->setParent(this);
		_subWidget->setLayout(ui->gridLayout);
		ui->gridLayout->addWidget(_subWidget);
	}

	//_subWidget->show();

}

FpHFSubWidget* FpHFMainWidget::GetSubWidget(QString typeName, int index)
{
	QString className = "class " + typeName;
	if (!_subMap.contains(className))
	{
		return nullptr;
	}
	return _subMap[className][index];
}

void FpHFMainWidget::Init()
{

}

FP_UIBASE_END